/**
 * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 *
 * For the applicable distribution terms see the license.txt -file, included in
 * the distribution.
 */

#ifndef DRMFILE_H
#define DRMFILE_H

#include <QObject>

class DRMFilePrivate;

/*!
  \class DRMFile class

  \brief Utility API intended to demonstrate and facilitate access to DRM protected
  content.

  The API has two private implementations, one Symbian specific - using the
  Content Access Framework (CAF) API - and an empty one which enables the API
  to be used (more like compiled) in the simulator
*/
class DRMFile : public QObject
{
    Q_OBJECT
    Q_DECLARE_PRIVATE(DRMFile)

public:
    /*!
      Constructor
    */
    explicit DRMFile(QObject *parent = 0);

    /*!
      Destructor
    */
    virtual ~DRMFile();

public:

    /*!
      open method for the specified file
      const QString & name - fully qualified file name and path.

      Will return a negative error code if the file opening fails. The error
      code should be checked with *isDRMError* in order to understand
    */
    int open(const QString & name);

    /*!
      Read max of *length* bytes into the provided *data* buffer
      Will return a negative error code or the length of the read data.

      if length is not given or equal to '0' it will allocate memory buffer to
      contain the whole data client must release allocated memory passed by
      reference pointer 'data'
    */
    int read(uchar*& data, int length = 0, int index = 0);

    /*!
      Closes the file.
    */
    void close();

    /*!
      Returns data item size referred by index in DRM container
    */
    int size(int index = 0);

    /*!
      returns DRM container size or negative error value
    */
    int count();

    /*!
      allocates memory for data item name or NULL if error happens
      'index'  - data item index in the DRM container
   */
    QString getName(int index);

protected:
    //data
    DRMFilePrivate* const d_ptr; //private implementation of the API
};

#endif // DRMFILE_H
